[XEN] Avoid use of GNU-specific memmem().
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Thu, 4 Jan 2007 10:17:34 +0000 (10:17 +0000)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Thu, 4 Jan 2007 10:17:34 +0000 (10:17 +0000)
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/tools/symbols.c

index ed126a2d06acfda629bc1b548b9e29f9370326f5..00f1a43037836dbba1009c47230d48cc6f0ec83c 100644 (file)
@@ -350,6 +350,14 @@ static void build_initial_tok_table(void)
        table_cnt = pos;
 }
 
+static void *memmem_pvt(void *h, size_t hlen, void *n, size_t nlen)
+{
+       char *p;
+       for (p = h; (p - (char *)h) <= (hlen - nlen); p++)
+               if (!memcmp(p, n, nlen)) return p;
+       return NULL;
+}
+
 /* replace a given token in all the valid symbols. Use the sampled symbols
  * to update the counts */
 static void compress_symbols(unsigned char *str, int idx)
@@ -363,7 +371,7 @@ static void compress_symbols(unsigned char *str, int idx)
                p1 = table[i].sym;
 
                /* find the token on the symbol */
-               p2 = memmem(p1, len, str, 2);
+               p2 = memmem_pvt(p1, len, str, 2);
                if (!p2) continue;
 
                /* decrease the counts for this symbol's tokens */
@@ -382,7 +390,7 @@ static void compress_symbols(unsigned char *str, int idx)
                        if (size < 2) break;
 
                        /* find the token on the symbol */
-                       p2 = memmem(p1, size, str, 2);
+                       p2 = memmem_pvt(p1, size, str, 2);
 
                } while (p2);